Skip to content

fix(svelte): hydrate server-rendered islands - #944

Merged
cpojer merged 1 commit into
mainfrom
fix/svelte-island-hydration
Nov 28, 2026
Merged

cpojer merged 1 commit into
mainfrom
fix/svelte-island-hydration

Conversation

@hyfdev

@hyfdev hyfdev commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Svelte islands are mounted again in the browser instead of hydrated, so their server HTML is replaced and anything typed before their JavaScript loads is lost.

Islands now hydrate their server HTML.

Svelte's hydrate() expects a pair of root comments in its target, and the island wrapper renders the component without them.

Before:

<div data-island="…" …><Cmp {...props} /></div>

After:

<div data-island="…" …>{#each [1] as _}<Cmp {...props} />{/each}</div>

The single-iteration {#each} makes the compiler emit that pair, so each island's server HTML gains two comments and nothing else.

Markdown islands get the same wrapper, and in dev it is compiled without the HMR comment that would land inside the pair.

Islands that hydrate separately can take over each other's <svelte:head> tags, so the islands guide now says to keep head content in pages and layouts.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-svelte-island-hydration-void-cloud.voidzero-docs.workers.dev (commit e16a01b)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://e417827a-void-cloud.voidzero-docs.workers.dev e16a01b 2026-11-27T06:15:14.766Z Visit the dashboard ↗

@hyfdev
hyfdev marked this pull request as ready for review November 27, 2026 06:21
Copilot AI balanced review requested due to automatic review settings November 27, 2026 06:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@cpojer
cpojer merged commit 0829e73 into main Nov 28, 2026
22 checks passed
@cpojer
cpojer deleted the fix/svelte-island-hydration branch November 28, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants